﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace YanForum.Engine.ViewModels
{
    public class PostItem
    {
        public int Id { get; set; }
        public string Title { get; set; }
        public string Content { get; set; }
        public string ThumbName { get; set; }
        public string ThumbFolder { get; set; }
        public string CreateUserName { get; set; }
        public int CreateUserId { get; set; }
        public DateTime? DateUpdate { get; set; }
        public string Url
        {
            get { return YanForum.Engine.Services.StringExtension.ToSlug(Title); }
        }

        public string ThumbFullPath
        {
            get
            {
                return YanForum.Engine.Services.BaseService.ImgServerPath + ThumbFolder + "/" + ThumbName;
            }
        }
    }

    public class PostIndex
    {
        public int TotalCount { get; set; }
        public List<PostItem> ListPost { get; set; }
        public PostOtions Options { get; set; }
    }
    public class PostOtions
    {
        public int PageSize { get; set; }
        public int PageIndex { get; set; }
        public string Search { get; set; }
        public int? UserId { get; set; }
    }

    public class PostUpdate
    {
        public int Id { get; set; }
        public int UserId { get; set; }

        [DisplayName("Tiêu đề bài viết")]
        [Required(ErrorMessage="Vui lòng nhập tiêu đề")]
        public string Title { get; set; }
        [DisplayName("Nội dung bài viết")]
        [Required(ErrorMessage = "Vui lòng nhập nội dung bài viết")]
        public string Content { get; set; }
        public string ThumbName { get; set; }
        public string ThumbFolder { get; set; }

        public string ImagePath { get; set; }
        public string ThumbFullPath
        {
            get
            {
                return YanForum.Engine.Services.BaseService.ImgServerPath + ImagePath;
            }
        }
    }
}
